﻿using BLL;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OAElectronics.Controllers
{
    [Authorize(Policy = "开发部")]
 
    public class DispatchacarController : Controller
    {
        private readonly DispatchacarBLL _dispatchacar;
        public DispatchacarController(DispatchacarBLL dispatchacar) 
        {
            _dispatchacar = dispatchacar;
        }
        [Authorize(Roles = "部门经理")]
        public int Index([FromBody] Dispatchacar d)
        {
            return _dispatchacar.Add(d);
        }
 
        public IEnumerable<Dispatchacar> Dispatchaca()
        {
             return _dispatchacar.dispatchacars();
            
        }
 
        public IEnumerable<Dispatchacar> Dispatchacal([FromBody] Dispatchacar d)
        {
            return _dispatchacar.dispatchacars().Where(x=>x.Objective.Contains(d.Objective));

        }
        [Authorize(Roles = "总经理")]
        public int update([FromBody] Dispatchacar d) 
        {
            return _dispatchacar.update(d.DisID,d.Travel_leader);
        }
    }
}
